package com.yimi.yinhepda.utils;

import android.content.Context;

import com.pda.uce.commom.util.AppUtil;
import com.pda.ym.callbacks.UICallBack;
import com.pda.ym.net.NetRequest;
import com.pda.ym.utils.AppInfoHelper;
import com.pda.ym.utils.Constants;
import com.pda.ym.utils.SharedPreferUtil;
import com.yimi.yinhepda.entity.response.CarPlanTaskResponse;
import com.yimi.yinhepda.entity.request.ErrorMsgRequest;

import java.util.HashMap;
import java.util.Map;

public class UploadErrorModule {
    public static UploadErrorModule uploadErrorModule;

    public static UploadErrorModule getInstance() {
        if (uploadErrorModule == null) {
            synchronized (UploadErrorModule.class) {
                if (uploadErrorModule == null) {
                    uploadErrorModule = new UploadErrorModule();
                }
            }
        }
        return uploadErrorModule;
    }


    public void uploadData(String errorType, String errorMsg, Context context){
        Map<String,String> mapHeaders=new HashMap<>();
        mapHeaders.put("token","d376141430e60ac8");
        String remark= "PDA"+AppInfoHelper.getAppVersionName(context)+",userCode="+ SharedPreferUtil.getInstance().getValue(Common.USER_CODE)+",部门="+SharedPreferUtil.getInstance().getValue(Common.DEPT_NAME);
        new NetRequest().setMethod(NetRequest.Method.POST_STRING)
                .setResponsClazz(CarPlanTaskResponse.class)
                .setUrl(Constants.URL_ERROR_UPLOAD)
                .setHeaders(mapHeaders)
                .setRequestObject(new ErrorMsgRequest(AppUtil.getIMEI(), errorType,errorMsg,remark))
                .execute(new UICallBack() {
                    @Override
                    public void onError(String msg) {
                    }

                    @Override
                    public void onSuccess(Object obj) {
                    }
                });

    }

}
